var express = require('express');
var router = express.Router();


let { addTypes,
  getTypes,
  deleteTypesId,
  getTypesId,
  modifyTypes,
  searchTypes

} = require('../service/typesService');

//新增保险分类
router.post('/addTypes', async function (req, res) {
  // console.log(111,req.body);
  res.send(await addTypes(req.body))
})


// 获取产品分类列表数据
router.get('/getTypes', async function (req, res) {
  let data = await getTypes(req.query)
  res.send(data)
})
//搜索
router.get('/searchTypes', async function (req, res) {
  let data = await searchTypes(req.query)
  res.send(data)
})


//获取点击删除时，产品分类下是否还有数据
router.get('/getTypesId', async function (req, res) {
  let data = await getTypesId(req.query)
  res.send(data)
})

//根据ID删除指定产品分类
router.post('/deleteTypesId', async function (req, res) {
  let { _id } = req.body
  let data = await deleteTypesId({ _id })
  res.send(data)
})

//  修改指定产品的数据
router.post('/modifyTypes', async function (req, res) {
  let data = await modifyTypes(req.body)
  res.send(data)
})


module.exports = router;
